/*
 * @Description: 
 * @Date: 2020-11-24 15:44:43
 * @LastEditors: lother
 * @LastEditTime: 2021-01-11 13:50:43
 * @FilePath: \AccounOpening-WEB\src\locale\index.js
 */
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import store from '../store'
Vue.use(VueI18n)

import customZhCn from './lang/zh-CN'
import customEnUs from './lang/en-US'
import customEnTw from './lang/zh-TW'

import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import enLocale from 'element-ui/lib/locale/lang/en'
import twLocale from 'element-ui/lib/locale/lang/zh-TW'

import zhOpen from '@/locales/zh-cn.json'
import enOpen from '@/locales/en-US.json'
import twOpen from '@/locales/zh-TW.json'
// 自动根据浏览器系统语言设置语言
const navLang = navigator.language
const localLang = (navLang === 'zh-CN' || navLang === 'en-US') ? navLang : false
let lang = store.state.settings.language || localLang || 'zh-CN'

Vue.config.lang = lang

const zh = {
  ...customZhCn,
  ...zhLocale,
  ...zhOpen
}
const en = {
  ...customEnUs,
  ...enLocale,
  ...enOpen
}
const tw = {
  ...customEnTw,
  ...twLocale,
  ...twOpen
}
export {
  zh,
  en,
  tw,
  lang
}
